/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ssdhddsimulator;

/**
 *
 * @author Kartikeya Dubey
 */
public class HDD {
    double filesize;
    double readtime    = 15360;
    double writetime   = 7168;
    double avgseektime = 8.5;
    double avglatency  = 4.16;

    HDD()
    {
    }

    //Read time is defined as
    //avg seek time + avg latency + actual transfer time
    double HDDReadTime(double size)
    {
        return (avgseektime + avglatency) + (size/readtime);
    }

    double HDDWriteTime(double size)
    {
        return (avgseektime + avglatency) + (size/writetime);
    }


    static double HDDCalculator(String fileOperation, double fileSize, int offset) {


        int OperationID;
        double HDDTime;
        double HDDPower;
        double Read;
        double Write;
        double ActivePower;


        //Calculating Read/Write Times
        //Refer to Intel® X18-M/X25-M SATA Solid State Drive Datasheet for specs
        //Need to be validated

        Read = 15; //MB per s
        Write = 7; //MB per s

        //Assuming filesize and offset are in MB
        if(fileOperation.equals("R"))
            HDDTime = (fileSize - offset)/Read;
        else
             HDDTime = (fileSize - offset)/Write;

        ActivePower = 150; //mW

        //Power consumed in the Operation
        //Assuming drive is active only during the Operation time
        HDDPower = HDDTime*ActivePower;

        //Returning only time for now
        return HDDTime;



    }


}
